<?php
// 加载通用文件
require_once __DIR__ . '/common/autoload.php';

// 检查是否已安装
if (!file_exists(__DIR__ . '/.installed')) {
    header('Location: /install.php');
    exit;
}

// 获取UA信息
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$is_mobile = strpos($ua, 'mobile') !== false || strpos($ua, 'android') !== false || strpos($ua, 'iphone') !== false;

// 根据不同的终端选择跳转目标
$target = '/POS/login.php'; // 默认跳转到POS终端

// 检查URL参数
$terminal = isset($_GET['terminal']) ? $_GET['terminal'] : '';

switch ($terminal) {
    case 'pos':
        $target = '/POS/login.php';
        break;
    case 'chef':
        $target = '/chushi/login.php';
        break;
    case 'display':
        $target = '/paidui/index.php';
        break;
    case 'user':
        $target = '/yh/index.php';
        break;
    default:
        // 根据UA自动判断
        if ($is_mobile) {
            $target = '/yh/index.php'; // 移动端跳转到用户中心
        } else {
            $target = '/POS/login.php'; // PC端跳转到POS终端
        }
        break;
}

// 跳转
header('Location: ' . $target);
exit;
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>餐饮收银系统</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            text-align: center;
            background-color: #f8f9fa;
            color: #333;
        }
        .container {
            padding: 20px;
            max-width: 600px;
        }
        h1 {
            color: #3498db;
            margin-bottom: 20px;
        }
        p {
            margin-bottom: 30px;
        }
        .loading {
            display: inline-block;
            width: 50px;
            height: 50px;
            border: 5px solid #f3f3f3;
            border-radius: 50%;
            border-top: 5px solid #3498db;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>餐饮收银系统</h1>
        <p>正在跳转到合适的终端...</p>
        <div class="loading"></div>
    </div>
</body>
</html> 